/*
 * Alloy Analyzer
 * Copyright (c) 2002 Massachusetts Institute of Technology
 *
 * The Alloy Analyzer is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * The Alloy Analyzer is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with the Alloy Analyzer; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

package alloy.ast;

public class TypeScope extends TreeNode {

    /** integer bound on scope */
    private final int _bound;
    
    /**
     * whether scope is exact or not
     */
    private final boolean _exact;
    /**
     * index of sig expr in child list
     */
    private static final int SIGEXPR_INDEX = 0;

    public TypeScope(Location location_, boolean exact_, int bound_, SigExpr sigExpr_) {
        super(location_, sigExpr_);
        _exact = exact_;
        _bound = bound_;
    }


    public TypeScope(boolean exact_, int bound_, SigExpr sigExpr_) {
        this(Location.UNKNOWN, exact_, bound_, sigExpr_);
    }



    //GET AND SET METHODS

    /**
     * gets the bound of this
     * @return the bound
     */
    public int getBound() {
        return _bound;
    }

    /**
     * sets the bound of this
     * @param bound_ the new bound for this
     */
//    public void setBound(int bound_) {
//        _bound = bound_;
//    }

    /**
     * gets the sigexpr of this
     * @return the {@link SigExpr}
     */
    public SigExpr getSigExpr() {
        return (SigExpr)childAt(SIGEXPR_INDEX);
    }

    /** set the SigExpr of this */
    public void setSigExpr(SigExpr newChild_) {
        setChild(SIGEXPR_INDEX, newChild_);
    }

    /**
     * accept an AST visitor
     * @param visitor_ the visitor
     */
    protected void acceptVisitor(ASTVisitor visitor_) {
        visitor_.visit(this);
    }

    /**
     * accept a returning AST visitor
     * @param visitor_ the visitor
     * @return the Object returned by the visitor
     */
    protected Object acceptReturnVisitor(ASTReturnVisitor visitor_) {
        return visitor_.visit(this);
    }

    public String nodeString() {
        return Integer.toString(_bound) + " " + getSigExpr().nodeString();
    }

    public String toString()
    {
        return nodeString();
    }
    /**
     * Returns the exact.
     * @return boolean
     */
    public boolean isExact() {
        return _exact;
    }

    /**
     * Sets the exact.
     * @param exact The exact to set
     */
//    public void setExact(boolean exact) {
//        _exact = exact;
//    }

}
